package com.shuai.blog.common;

import com.shuai.blog.entity.UserInfo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

public class UserSessionUtils {

    public static UserInfo getUserInfo(HttpServletRequest request) {
        HttpSession session = request.getSession(false);
        if (session == null || session.getAttribute(AppConstant.USER_SESSION_KEY) == null) {
            return null;
        }
        return (UserInfo) session.getAttribute(AppConstant.USER_SESSION_KEY);
    }

}
